'use strict'

var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault')

exports.__esModule = true
exports.default = createLeftPlugin

var _parser = _interopRequireDefault(require('./parser'))

function createLeftPlugin(_temp) {
  var _ref = _temp === void 0 ? {} : _temp,
    _ref$name = _ref.name,
    name = _ref$name === void 0 ? 'left' : _ref$name

  var commandHandler = function commandHandler(editor, type) {
    if (type === void 0) {
      type = 'left'
    }

    editor.insert(function (selected) {
      var prefix = ':::'
      var suffix = ':::'
      var content = selected || '请输入内容'
      return {
        text: prefix + ' ' + type + '\n  ' + content + '\n' + suffix,
        selected: content
      }
    })
  }
  return {
    install: function install(VMdEditor) {
      VMdEditor.command(name, commandHandler)
      VMdEditor.vMdParser.use(_parser.default)
    }
  }
}
